package alibaba.ifelserefactor.demo01.test03;

import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import static alibaba.ifelserefactor.demo01.ShareType.TYPE_LINK;
import static alibaba.ifelserefactor.demo01.ShareType.TYPE_TEXT;

/**
 * @author ChangLiang
 * @date 2020/4/20
 */
@Slf4j
public class ShareServiceTest {

    /**
     * 或者有人会说，这样用户也需额外了解多几个方法。
     * 我个人觉得让用户了解多几个方法好过了解多几个类，而已方法名一看就能知道意图，成本还是挺小，是可以接受的。
     */

    @Test
    @DisplayName("前端调用分享link 只需要了解这个方法")
    public void test() {
        ShareItem shareItem = ShareItem.createLinkShareItem(TYPE_LINK, "", "");
        ShareService shareService = new ShareService();
        shareService.share(shareItem, (state, msg) -> log.info(msg));
    }

    @Test
    @DisplayName("前端调用分享Text 只需要了解这个方法")
    public void test2() {
        ShareItem shareItem = ShareItem.createTextShareItem(TYPE_TEXT);
        ShareService shareService = new ShareService();
        shareService.share(shareItem, (state, msg) -> log.info(msg));
    }
}
